let audioBtnJ = "";
let audioBtnK = "";
const audio = new Audio('./static/voice.mp3'); // 背景音乐
$(function(){
  $('.primary-btn').click(function(){
    $('body').toggleClass('dark')
    $('body').toggleClass('light')
  })
  $('#audioBtn').click(function(){
    console.log('aa', audio.paused)
    if (audio.paused) { // 如果音频处于暂停状态
      audio.play(); // 播放音频
      $('#audioBtn').html(audioBtnK);
      $(this).addClass('play');
    }else{
      audio.pause(); // 暂停音频
      $('#audioBtn').html(audioBtnJ);
      $(this).removeClass('play');
    }
  })
  
  setSvg();
  // 调用检测函数
  checkAutoplaySupport();
  keydownFun()
})

function checkAutoplaySupport() {
  audio.play().then(() => {
    console.log('自动播放支持');
    $('#audioBtn').html(audioBtnK);
  }).catch((error) => {
    $('#audioBtn').html(audioBtnJ);
    console.log('自动播放不支持', error);
  });
}
// svg
function setSvg(){
  // svg -- logo
  let logoSvg = `<svg class="logo" width="40px" height="40px" viewBox="0 0 40 40" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g id="Logo" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
      <path d="M20.0671081,0 C30.3605795,0 38.8438888,7.72431597 40,17.6743643 L24.5093561,17.6744223 C23.6695585,16.0842567 21.9953799,15 20.0671081,15 C17.2964192,15 15.0503311,17.2385761 15.0503311,20 C15.0503311,22.7614239 17.2964192,25 20.0671081,25 C21.86719,25 23.4458398,24.0551122 24.3309766,22.6358384 L39.9614898,22.6358757 C38.6669405,32.4357854 30.2533465,40 20.0671081,40 C8.98434921,40 0,31.0456949 0,20 C0,8.95430512 8.98434921,0 20.0671081,0 Z" fill="#161616" fill-rule="nonzero"></path>
    </g>
  </svg>`;
  $('#logo').html(logoSvg);
  
  // svg -- 背景音乐
  audioBtnJ = `<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      <g id="背景音乐" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <path d="M8.54166667,1 L9.51363557,1.22734072 L14.6133147,2.42014092 L15.2246792,2.5631373 L15.2246792,7.4018072 L14.2503466,7.17075923 L10.125,6.192 L10.125,8.275 L14.9896692,9.5784699 L14.6014407,11.0273586 L10.125,9.828 L10.125,14.2531941 C10.125,15.7922217 8.87736084,17.0398608 7.33833333,17.0398608 L5.78666667,17.0398608 C4.24763916,17.0398608 3,15.7922217 3,14.2531941 L3,13.8890275 C3,12.35 4.24763916,11.1023608 5.78666667,11.1023608 L8.541,11.102 L8.541,9.403 L3.01033076,7.9215301 L3.39855933,6.47264136 L8.541,7.85 L8.54166667,1 Z M10.125,2.995 L10.125,4.564 L13.6413333,5.39820206 L13.6413333,3.81820206 L10.125,2.995 Z" fill="#161616" fill-rule="nonzero" opacity="0.5"></path>
      </g>
  </svg>`
  audioBtnK = `<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      <g id="icon/开启音乐" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <path d="M8.54166667,1 L9.51363557,1.22734072 L14.6133147,2.42014092 L15.2246792,2.5631373 L15.2246792,7.4018072 L14.2503466,7.17075923 L10.125,6.192 L10.125,14.2531941 C10.125,15.7922217 8.87736084,17.0398608 7.33833333,17.0398608 L5.78666667,17.0398608 C4.24763916,17.0398608 3,15.7922217 3,14.2531941 L3,13.8890275 C3,12.35 4.24763916,11.1023608 5.78666667,11.1023608 L8.541,11.102 L8.54166667,1 Z M10.125,2.995 L10.125,4.564 L13.6413333,5.39820206 L13.6413333,3.81820206 L10.125,2.995 Z" fill="#161616" fill-rule="nonzero" opacity="0.5"></path>
      </g>
  </svg>`
  
  
  // svg -- 语言
  let lanBtn=`<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      <g id="切换英文" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
          <path d="M3.44,4.22 L7.16,4.22 L7.16,2 L1,2 L1,15.8 L7.16,15.8 L7.16,13.6 L3.44,13.6 L3.44,9.88 L6.64,9.88 L6.64,7.68 L3.44,7.68 L3.44,4.22 Z M16.3,2 L13.84,2 L13.84,9.68 L10.96,2 L8.5,2 L8.5,15.8 L10.96,15.8 L10.96,8.44 L13.84,15.8 L16.3,15.8 L16.3,2 Z" fill="#161616" fill-rule="nonzero" opacity="0.5"></path>
      </g>
  </svg>`
  $('.lan-btn').html(lanBtn);
  
  // svg -- 主题色
  let primaryBtn=`<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g id="主题色" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
      <path
        d="M9,0 C13.9705627,-1.77635684e-15 18,4.02943725 18,9 C18,13.9705627 13.9705627,18 9,18 C4.02943725,18 0,13.9705627 0,9 C0,4.02943725 4.02943725,0 9,0 Z M9.00100268,1.50000007 L9,16.499 L9.24273105,16.4961464 C13.2725256,16.3680175 16.5,13.0609173 16.5,9 C16.5,4.85819861 13.1426775,1.5005419 9.00100268,1.50000007 Z" fill="#161616" opacity="0.5"></path>
    </g>
  </svg>`
  $('.primary-btn').html(primaryBtn);
  
  
  // svg -- 联系我们
  let contactBtn=`<svg width="14px" height="14px" viewBox="0 0 14 14" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g id="控件" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
      <g id="Button/与我联系/Light" transform="translate(-34.000000, -13.000000)" fill="#161616" fill-rule="nonzero">
        <g id="feedback" transform="translate(34.000000, 13.000000)">
          <path
            d="M6.54883,9.0781 C7.00911,9.2604 7.42839,9.502 7.80664,9.8027 C8.1849,10.1035 8.50846,10.4521 8.77734,10.8486 C9.0462,11.2451 9.2536,11.6712 9.3994,12.127 C9.5452,12.5827 9.6204,13.0612 9.625,13.5625 L9.625,14 L8.5,14 L8.5,13.5625 C8.5,13.0202 8.5,12.5 8.25,12 C8,11.5 7.5,11 7.25,10.75 C7,10.5 6.75,10.25 6.25,10 C5.75,9.75 5.29688,9.7546 4.75,9.75 C4.20768,9.75 3.97852,9.7949 3.5,10 C3.02148,10.2051 2.60547,10.3899 2.25,10.75 C1.89453,11.11 1.45508,11.7761 1.25,12.25 C1.04493,12.724 1.00456,13.0156 1,13.5625 L1,14 L0,14 L0,13.5625 C0,13.0658 0.07292,12.5872 0.21875,12.127 C0.36458,11.6667 0.57422,11.2406 0.84766,10.8486 C1.12109,10.4567 1.44466,10.1104 1.81836,9.8096 C2.19206,9.5088 2.61133,9.265 3.07617,9.0781 C2.87109,8.93685 2.68652,8.77279 2.52246,8.58594 C2.3584,8.39909 2.2194,8.19857 2.10547,7.98438 C1.99154,7.77018 1.90495,7.54232 1.8457,7.30078 C1.78646,7.05924 1.75456,6.81315 1.75,6.5625 C1.75,6.13867 1.82975,5.74219 1.98926,5.37305 C2.14876,5.00391 2.36751,4.68034 2.64551,4.40234 C2.9235,4.12435 3.24707,3.9056 3.61621,3.74609 C3.98535,3.58659 4.38411,3.50456 4.8125,3.5 C5.23633,3.5 5.63281,3.57975 6.00195,3.73926 C6.37109,3.89876 6.69466,4.11751 6.97266,4.39551 C7.25065,4.6735 7.4694,4.99707 7.62891,5.36621 C7.78841,5.73535 7.87044,6.13411 7.875,6.5625 C7.875,6.81315 7.84538,7.05697 7.78613,7.29395 C7.72689,7.53092 7.63802,7.75879 7.51953,7.97754 C7.40104,8.19629 7.26204,8.39909 7.10254,8.58594 C6.94303,8.77279 6.75846,8.93685 6.54883,9.0781 Z M4.8125,8.5625 C5.08749886,8.5625 5.34583029,8.51041314 5.58750343,8.40624857 C5.82916743,8.302084 6.03958114,8.16041543 6.21875371,7.981252 C6.39791714,7.80207943 6.54167029,7.58958114 6.650004,7.343748 C6.75833771,7.09791486 6.8125,6.83749886 6.8125,6.5625 C6.8125,6.28750114 6.76041314,6.02916971 6.65624857,5.78749657 C6.552084,5.54583257 6.40833086,5.33541886 6.22499829,5.15624629 C6.04166571,4.97708286 5.82916743,4.83332971 5.58750343,4.724996 C5.34583029,4.61666229 5.08749886,4.5625 4.8125,4.5625 C4.53750114,4.5625 4.27916971,4.61458686 4.03749657,4.71875143 C3.79583257,4.822916 3.58333429,4.96666914 3.40000171,5.15000171 C3.21666914,5.33333429 3.072916,5.54583257 2.96875143,5.78749657 C2.86458686,6.02916971 2.8125,6.28750114 2.8125,6.5625 C2.8125,6.83749886 2.86458686,7.09583029 2.96875143,7.33750343 C3.072916,7.57916743 3.21458457,7.79166571 3.393748,7.97499829 C3.57292057,8.15833086 3.78541886,8.302084 4.031252,8.40624857 C4.27708514,8.51041314 4.53750114,8.5625 4.8125,8.5625 Z M14,0 L14,7 L12.25,7 L9.625,9.625 L9.625,7 L8.75,7 L8.75,6 L10.5,6 L10.5,7.25 L11.75,6 L13,6 L13,1 L4.5,1 L4.5,2.5 C4.25,2.5 4.08333,2.48828 3.9375,2.51562 C3.79167,2.54297 3.64583,2.58398 3.5,2.63867 L3.5,0 L14,0 Z"
            id="形状"></path>
        </g>
      </g>
    </g>
  </svg>`
  $('#contactBtn').html(contactBtn);
  
  
  let pageSvg = `<svg t="1743526568648" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1498" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M3.190031 461.9563864l861.30841101-1e-8L864.49844201 541.70716539 3.190031 541.70716539l0-79.75077899z" fill="#161616" p-id="1499"></path><path d="M823.02803698 382.20560738L1023.99999999 500.23676039l-200.97196301 121.22118402 0-239.25233703z" fill="#161616" p-id="1500"></path></svg>`
  if( $('.page-btn').length > 0 ){
    $('.page-btn .page-svg').html(pageSvg)
  }
}


function keydownFun (){
  document.addEventListener('keydown', function(event) {
      // 检测 F12 键 (keyCode 为 123)
      if (event.keyCode === 123) {
          // 阻止默认行为（可选）
          event.preventDefault();
  
          // 跳转到空白页面
          window.location.href = 'about:blank';
      }
  
      // 检测组合键 (Ctrl + Shift + I 或 Ctrl + Shift + C)
      if ((event.ctrlKey || event.metaKey) && event.shiftKey && (event.key === 'I' || event.key === 'C')) {
          event.preventDefault();
          window.location.href = 'about:blank';
      }
      
      
      
      // 检测 Ctrl+U 或 Cmd+U
      if ((event.ctrlKey || event.metaKey) && event.key === 'u') {
          event.preventDefault(); // 阻止默认行为
          window.location.href = 'about:blank'; // 跳转到空白页面
      }
  });
  
}